package com.box.app.arithmetic

sealed interface Arithmetic : Describable {
    operator fun plus(other: Arithmetic): Expression {
        val elements = mutableListOf<Factor>()
        when (this) {
            is Factor -> elements.add(this)
            is Expression -> elements.addAll(this)
        }
        when (other) {
            is Factor -> elements.add(other)
            is Expression -> elements.addAll(other)
        }
        return Expression(elements)
    }
}